package com.mindskip.xzs.service.impl;

import com.mindskip.xzs.domain.ExamPaper;
import com.mindskip.xzs.dto.CorrectingDto;
import com.mindskip.xzs.repository.CorrectingMapper;
import com.mindskip.xzs.service.CorrectingService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CorrectingServiceImpl implements CorrectingService {

    private final CorrectingMapper correctingMapper;

    public CorrectingServiceImpl(CorrectingMapper correctingMapper) {
        this.correctingMapper = correctingMapper;
    }

    @Override
    public List<CorrectingDto> getPendingPapers(Integer subjectId) {

        return correctingMapper.getPendingPapers(subjectId);
    }

    @Override
    public CorrectingDto getPaperDetail(Integer paperId) {
        return correctingMapper.getPaperDetail(paperId);
    }

    @Override
    public void gradePaper(Integer paperId, List<CorrectingDto> correctedAnswers) {

    }

//    @Override
//    public void gradePaper(Integer paperId, List<CorrectingDto> correctedAnswers) {
//        ExamPaper examPaper = correctingMapper.gradePaper(paperId);
//
//        for (CorrectingDto correctedAnswer : correctedAnswers) {
//            Integer questionId = correctedAnswer.getQuestionId();
//            Integer questionScore = correctedAnswer.getQuestionScore();
//
//            // 更新试卷答案或者存储到数据库中（具体操作根据业务需求而定）
//            updateAnswerInPaper(examPaper,questionId,questionScore);
//        }
//        // 更新试卷状态等信息（具体操作根据业务需求而定）
//        updatePaperStatus(examPaper);
//    }

    private void updateAnswerInPaper(ExamPaper examPaper, Integer questionId, Integer questionScore) {

    }
    private void updatePaperStatus(ExamPaper examPaper) {

    }
}
